package com.yserp.project.erp.store.inorder.controller;

import com.yserp.common.utils.poi.ExcelUtil;
import com.yserp.framework.aspectj.lang.annotation.Log;
import com.yserp.framework.aspectj.lang.enums.BusinessType;
import com.yserp.framework.web.controller.BaseController;
import com.yserp.framework.web.domain.AjaxResult;
import com.yserp.framework.web.page.TableDataInfo;
import com.yserp.project.erp.store.inorder.domain.InOrderItem;
import com.yserp.project.erp.store.inorder.service.IInOrderItemService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商品入库单子Controller
 * 
 * @author yserp
 * @date 2022-07-15
 */
@Controller
@RequestMapping("/store/inorder/item")
public class InOrderItemController extends BaseController
{
    private String prefix = "store/inorder";

    @Autowired
    private IInOrderItemService inOrderItemService;

    @RequiresPermissions("store:inorder:view")
    @GetMapping()
    public String inorder()
    {
        return prefix + "/inorder";
    }

    /**
     * 查询商品入库单子列表
     */
    @RequiresPermissions("store:inorder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(InOrderItem inOrderItem)
    {
        startPage();
        List<InOrderItem> list = inOrderItemService.selectInOrderItemList(inOrderItem);
        return getDataTable(list);
    }

    /**
     * 导出商品入库单子列表
     */
    @RequiresPermissions("store:inorder:export")
    @Log(title = "商品入库单子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(InOrderItem inOrderItem)
    {
        List<InOrderItem> list = inOrderItemService.selectInOrderItemList(inOrderItem);
        ExcelUtil<InOrderItem> util = new ExcelUtil<InOrderItem>(InOrderItem.class);
        return util.exportExcel(list, "商品入库单子数据");
    }


}
